#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H

/* do we even need a resource manager? why not pass pointers? */

#include <base/d3d.h>

#include <string>
#include <vector>

#define RM_UNKNOWN 0x00
#define RM_TEXTURE 0x01
#define RM_SOUND   0x02
#define RM_MUSIC   0x03
#define RM_SHADER  0x04

class Device;

class Resource {
public:
  Resource(unsigned long type);
  virtual ~Resource() {};
  //long _load(std::string filename) {return 0;};
private:
  unsigned long _type;
};

class DeviceResource : public Resource{
public:
  DeviceResource(Device * device, unsigned long type);
  virtual ~DeviceResource() {};
  //long _load(std::string filename) {return 0;};
private:
  unsigned long _type;
  Device * _device;
};

class Texture : public DeviceResource {
public:
  Texture(std::string filename, Device * device);
  ~Texture();

  LPDIRECT3DTEXTURE9 getTexture();

private:
  LPDIRECT3DTEXTURE9 _texture;
};

class Shader : public DeviceResource {
public:
  Shader(std::string filename, Device * device);
  ~Shader();

  LPD3DXEFFECT getShader();
  long addTechnique(std::string name);
  void setTechnique(long tech);

private:
  LPD3DXEFFECT _shader;
  std::vector<D3DXHANDLE> _values;
};

long DestroyResources();

// returns index of resource, -1 on failure
long LoadResourceFromFile(long type, std::string filename, Device * device = NULL);
long LoadResourceFromMemory(long type, std::string filename, Device * device = NULL);

Resource * GetResource(long index);

#endif
